package com.kuang.lesson03.chat

import java.net.DatagramPacket
import java.net.DatagramSocket

fun main() {
    val buffer = ByteArray(DEFAULT_BUFFER_SIZE)
    DatagramSocket(9666).use {
        while (true) {
            val packet = DatagramPacket(buffer, buffer.size)
            it.receive(packet)
            packet.address
            val msg = String(packet.data, 0, packet.length)
            println(msg)
            if ("bye" == msg) break
        }
    }
}